#ifndef __REFEREE_H
#define __REFEREE_H


#include "referee_protocol.h"
#include "robotdef.h"

#pragma pack(1)
typedef struct
{
	uint8_t Robot_Color;		// 机器人颜色
	uint16_t Robot_ID;			// 本机器人ID
	uint16_t Cilent_ID;			// 本机器人对应的客户端ID
	uint16_t Receiver_Robot_ID; // 机器人车间通信时接收者的ID，必须和本机器人同颜色
} referee_id_t;

// 此结构体包含裁判系统接收数据以及UI绘制与机器人车间通信的相关信息
typedef struct
{
	referee_id_t referee_id;

	xFrameHeader FrameHeader; // 接收到的帧头信息
	uint16_t CmdID;
	ext_game_state_t GameState;							   // 0x0001
	ext_game_result_t GameResult;						   // 0x0002
	ext_game_robot_HP_t GameRobotHP;					   // 0x0003
	ext_event_data_t EventData;							   // 0x0101
	ext_supply_projectile_action_t SupplyProjectileAction; // 0x0102
	ext_game_robot_state_t GameRobotState;				   // 0x0201
	ext_power_heat_data_t PowerHeatData;				   // 0x0202
	ext_game_robot_pos_t GameRobotPos;					   // 0x0203
	ext_buff_musk_t BuffMusk;							   // 0x0204
	aerial_robot_energy_t AerialRobotEnergy;			   // 0x0205
	ext_robot_hurt_t RobotHurt;							   // 0x0206
	ext_shoot_data_t ShootData;							   // 0x0207
	ext_shoot_remaing_t ext_shoot_remaing;				   // 0x0208
	rfid_status_t rfid_status;							   // 0x0209

	// 自定义交互数据的接收
	Communicate_ReceiveData_t ReceiveData;

	uint8_t init_flag;

} referee_info_t;

#pragma pack()


/**
 * @brief UI绘制和交互数的发送接口,由UI绘制任务和多机通信函数调用
 *
 * @param send 发送数据首地址
 * @param tx_len 发送长度
 */
void RefereeSend(uint8_t *send, uint16_t tx_len);

void read_referee_powerinfo(float* chassis_max_power,float* buffer_energy);

void read_referee_robot_hp(float* robot_hp,rt_uint8_t* hurt_type);

void JudgeReadData(uint8_t *buff);

void chassis_to_gimbal(Chassis_Upload_Data_s *Chassis_Upload_Data);

rt_uint8_t read_referee_game_progress(void);

#endif 
